package com.junmo.common.enums;

import com.junmo.common.result.IResultCode;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 异常提示
 **/
@AllArgsConstructor
@NoArgsConstructor
public enum RemindCode implements IResultCode, Serializable {

    SYSTEM_REMIND("600", "操作异常"),
    PHONE_NULL_REMIND("601", "手机号码不能为空"),
    PASSWORD_NOT_SAME_REMIND("602", "两次密码输入不相同"),
    PHONE_USER_EXIST_REMIND("603", "该手机号以注册，您可以使用手机号登录"),
    MESSAGE_CODE_ERROR_REMIND("604", "您输入的验证码不正确"),
    USER_PASSWORD_ERROR_REMIND("605", "您输入的密码有误"),
    USER_PASSWORD_NOT_NULL_REMIND("606", "输入密码不能为空"),
    USER_PASSWORD_SAME_OLD_REMIND("607", "新密码与旧密码相同"),
    PASSWORD_RESERT_ERROR("608", "密码设置失败"),
    USER_CAPTCHA_IN_USE("609", "验证码10分钟内，仍然有效"),
    USER_ACCOUNT_REMOVE("610", "用户已注销"),
    USER_ACCOUNT_FREEZE("611", "用户已冻结"),
    USER_NO_ACCOUNT("612", "用户不存在"),
    USER_CAPTCHA_SEND_ERROR("613", "验证码发送失败"),
    ;

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    private String code;

    private String msg;

    @Override
    public String toString() {
        return "{" +
                "\"code\":\"" + code + '\"' +
                ", \"msg\":\"" + msg + '\"' +
                '}';
    }


    public static RemindCode getValue(String code){
        for (RemindCode value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return SYSTEM_REMIND; // 默认系统执行错误
    }
}
